//
//  TDExampleViewController.m
//  TFB
//
//  Created by yull on 15/8/15.
//  Copyright (c) 2015年 TD. All rights reserved.
//

#import "TDExampleViewController.h"
#import "TDRealNameCertificationTableViewController.h"
#import "TDBindingCardTableViewController.h"

@interface TDExampleViewController ()

@property (nonatomic, strong) UIScrollView *exampleView;

@end

@implementation TDExampleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = self.isRealNameCer ? @"实名认证" : @"绑定银行卡";
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    [self initExampleView];
}

- (void)initExampleView
{
//    UIScrollView *exampleView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
//    exampleView.autoresizingMask = self.view.autoresizingMask;
//    exampleView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    UILabel *titleL = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, self.view.frame.size.width, 20)];
    titleL.textAlignment = NSTextAlignmentCenter;
    titleL.text = @"示例照";
    titleL.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:titleL];
    
    UIImageView *exampleIV = [[UIImageView alloc] initWithImage:self.isRealNameCer ? [UIImage imageNamed:@"idcard.jpg"] : [UIImage imageNamed:@"bank_example.jpg"]];
    exampleIV.frame = CGRectMake(0, 30, self.view.frame.size.width, self.view.frame.size.height - 90);
    exampleIV.contentMode = UIViewContentModeScaleAspectFit;
    exampleIV.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [self.view addSubview:exampleIV];
    
    UIButton *goEditBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    goEditBtn.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
    goEditBtn.frame = CGRectMake(10, CGRectGetMaxY(exampleIV.frame) + 10, self.view.frame.size.width - 20, 44);
    goEditBtn.backgroundColor = MainColor;
    [goEditBtn setTitle:@"填写信息" forState:0];
    [goEditBtn setTitleColor:[UIColor whiteColor] forState:0];
    [goEditBtn addTarget:self action:@selector(onClickGoEditBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:goEditBtn];
    
//    exampleView.contentSize = CGSizeMake(1, CGRectGetMaxY(goEditBtn.frame) + 20);
//    [self.view addSubview:exampleView];
//    self.exampleView = exampleView;
}

- (void)onClickGoEditBtn:(id)sender
{
    if (self.isRealNameCer) {
        TDRealNameCertificationTableViewController *controller = [[TDRealNameCertificationTableViewController alloc] initWithStyle:UITableViewStylePlain];
        controller.hidesBottomBarWhenPushed = YES;
        
        NSMutableArray *vcs = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
        [vcs removeLastObject];
        [vcs addObject:controller];
        [self.navigationController setViewControllers:vcs animated:YES];
    } else {
        TDBindingCardTableViewController *controller = [[TDBindingCardTableViewController alloc] initWithStyle:UITableViewStylePlain];
        controller.hidesBottomBarWhenPushed = YES;
        
        NSMutableArray *vcs = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
        [vcs removeLastObject];
        [vcs addObject:controller];
        [self.navigationController setViewControllers:vcs animated:YES];
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
